#[macro_use] extern crate lazy_static;

pub mod posts_dao;

use diesel::{Connection, MysqlConnection};
use posts_dao::PostDao;
use config::CONFIG;

lazy_static! {
    pub static ref POST_DAO:PostDao = PostDao;
}

pub fn establish_connection() -> MysqlConnection {

    let database_url = &CONFIG.mysql_url;
    MysqlConnection::establish(&database_url)
        .unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
}

